#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int m, n;
    scanf("%d %d", &m, &n);
    int arr1[2000] = { 0 };
    for (int i = 0; i < n + m; i++)
    {
        scanf("%d", &arr1[i]);
    }
    for (int i = 0; i < n + m - 1; i++)
    {
        for (int j = 0; j < n + m - 1 - i; j++)
        {
            if (arr1[j] > arr1[j + 1])
            {
                int t = arr1[j];
                arr1[j] = arr1[j + 1];
                arr1[j + 1] = t;
            }
        }
    }
    for (int i = 0; i < n + m; i++)
    {
        printf("%d ", arr1[i]);
    }
}